var t = getApp()
Page({
  data: {
    info:'',
    navHeight:t.globalData.navHeight,
    title:'添加地址',
  },
  onLoad: function (options) {
    console.log(options);
    if (options) {
      this.setData({
        info:JSON.parse(options.item)
      })
    }
  },
  onRefresh(){
    //在当前页面显示导航条加载动画
    wx.showNavigationBarLoading(); 
    //显示 loading 提示框。需主动调用 wx.hideLoading 才能关闭提示框
  },
  onPullDownRefresh: function () {
    //调用刷新时将执行的方法
    this.onRefresh();
    setTimeout(function () {
      // 不加这个方法真机下拉会一直处于刷新状态，无法复位
      wx.stopPullDownRefresh()
    }, 1000)
  },
  formSubmit(e){
    var that = this
    console.log(e.detail.value);
    var usemessage = e.detail.value
    var o = {
      id:this.data.info.id,
      name:usemessage.name,
      phone:usemessage.tel,
      location:usemessage.location,
      address:usemessage.address,
    }
    t.request('/UserAddr/update',o,function(e){
      console.log(e);
      if (e.code==200) {
        wx.showToast({
          title: '修改成功',
        })
        wx.navigateBack({
          delta: 0,
        })
      }
    })
  },
})